package com.music.tools;

import com.ipod.main.R;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class GridMusicListAdapter extends BaseAdapter {

	private Context mcontext;
	private Cursor mcursor;
	
	public GridMusicListAdapter(Context con, Cursor cursor) {
		mcontext = con;
		mcursor = cursor;
	}
	@Override
	public int getCount() {
		return mcursor.getCount();
	}

	@Override
	public Object getItem(int position) {

		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = LayoutInflater.from(mcontext).inflate(
				R.layout.main_textview, null);
		mcursor.moveToPosition(position);
		ImageView images=(ImageView)convertView.findViewById(R.id.main_images);
		images.setImageResource(R.drawable.item);
	    TextView music_title = (TextView) convertView
				.findViewById(R.id.main_musicname);
		music_title.setText(mcursor.getString(0));
		TextView tv_singer = (TextView) convertView.findViewById(R.id.main_musicsinger);
		tv_singer.setText(mcursor.getString(2));
		return convertView;
	}

}
